const initField = function(ui) {
	const obj = {
		'element': {
			label: 'label',
			prop: 'prop'
		},
		'iview': {
			label: 'title',
			prop: 'slot'
		}
	}
	return obj[ui];
}

const getIcon = function(elementIcon, iviewIcon, ui) {
	if (ui === 'element') {
		return {
			icon: elementIcon
		}
	} else {
		return {
			attrs: {
				icon: iviewIcon,
				shape: 'circle'
			}
		}
	}
}

export default {
	mpsl1() {
		const { prop, label } = initField(this.ui);
		return [{
				[prop]: 'projectName',
				[label]: '项目名称'
			}, {
				[prop]: 'projectType',
				[label]: '项目类型'
			},
			{
				[prop]: 'projectAddress',
				[label]: '项目地址',
				'show-overflow-tooltip': true,
			},
			{
				[prop]: 'createTime',
				[label]: '创建时间',
			}, {
				[prop]: 'startTime',
				[label]: '开始时间',
			},
			{
				[prop]: 'endTime',
				[label]: '结束时间',
			},
			{
				[prop]: 'projectState',
				[label]: '项目状态',
				numToText: ['立项', '在建', '竣工']
			},
			{
				[prop]: 'name',
				[label]: '创建人',
			}
		]
	},
	mpsl2() {
		const { prop, label } = initField(this.ui);
		return [{
				[prop]: 'business',
				[label]: '商家'
			},
			{
				[prop]: 'expressCompany',
				[label]: '快递公司',
			},
			{
				[prop]: 'shippingAddress',
				[label]: '发货地址',
				'show-overflow-tooltip': true,
			},
			{
				[prop]: 'orderTime',
				[label]: '下单时间'
			},
			{
				[prop]: 'deliveryTime',
				[label]: '发货时间',
			},
			{
				[prop]: 'arrivalTime',
				[label]: '到货时间',
			},
			{
				[label]: "操作",
				[prop]: 'action',
				width: "90",
				tools: {
					delete: {
						...getIcon('el-icon-delete', 'ios-trash', this.ui),
						type: "warning",
						tipText: "删除",
					}
				}
			}
		]
	},
	//单页单表
	spsl() {
		const { prop, label } = initField(this.ui);
		return [{
				[prop]: 'projectName',
				[label]: '项目名称'
			},
			{
				[prop]: 'projectAddress',
				[label]: '项目地址',
				'show-overflow-tooltip': true,
			},
			{
				[prop]: 'createTime',
				[label]: '创建时间',
			},
			{
				[prop]: 'projectState',
				[label]: '项目状态',
				numToText: ['立项', '在建', '竣工']
			},
			{
				[label]: "操作",
				[prop]: 'action',
				width: "120",
				fixed: 'right',
				tools: {
					//点击会触发页面同名函数,即回调页面中名为detail的function
					detail: {
						...getIcon('el-icon-tickets', 'ios-eye', this.ui),
						type: "success",
						tipText: "查看详情"
					},
					delete: {
						...getIcon('el-icon-delete', 'ios-trash', this.ui),
						type: "warning",
						tipText: "删除"
					}
				}
			}
		]
	}
}
